﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer.stmt.teradata
{
	// Token: 0x020000D0 RID: 208
	public class TTeradataCreateProcedure : TStoredProcedureSqlStatement
	{
		// Token: 0x06000769 RID: 1897 RVA: 0x003009A5 File Offset: 0x002FEBA5
		public TTeradataCreateProcedure(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstteradatacreateprocedure;
		}

		// Token: 0x1700015C RID: 348
		// (get) Token: 0x0600076A RID: 1898 RVA: 0x003009B9 File Offset: 0x002FEBB9
		// (set) Token: 0x0600076B RID: 1899 RVA: 0x003009C1 File Offset: 0x002FEBC1
		public virtual TObjectName ProcedureName
		{
			get
			{
				return this.procedureName;
			}
			set
			{
				this.procedureName = value;
			}
		}

		// Token: 0x0600076C RID: 1900 RVA: 0x003009CC File Offset: 0x002FEBCC
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			if (!(this.rootNode is TCreateProcedureSqlNode))
			{
				return -1;
			}
			TCreateProcedureSqlNode tcreateProcedureSqlNode = (TCreateProcedureSqlNode)this.rootNode;
			base.doParseStatement(psql);
			this.procedureName = tcreateProcedureSqlNode.ProcedureName;
			base.DatabaseObjects.Add(this.procedureName);
			this.ParameterDeclarations = tcreateProcedureSqlNode.Parameters;
			if (this.ParameterDeclarations != null)
			{
				for (int i = 0; i < this.ParameterDeclarations.size(); i++)
				{
					this.TopStatement.SymbolTable.Push(new TSymbolTableItem(9, this, this.ParameterDeclarations.getParameterDeclarationItem(i)));
				}
			}
			if (tcreateProcedureSqlNode.Stmts != null)
			{
				tcreateProcedureSqlNode.Stmts.doParse(this, ESqlClause.unknown);
				for (int j = 0; j < tcreateProcedureSqlNode.Stmts.size(); j++)
				{
					this.BodyStatements.add(tcreateProcedureSqlNode.Stmts.getStatementSqlNode(j).Stmt);
				}
			}
			if (this.ParameterDeclarations != null)
			{
				for (int k = 0; k < this.ParameterDeclarations.size(); k++)
				{
					this.TopStatement.SymbolTable.Pop();
				}
			}
			return 0;
		}

		// Token: 0x0600076D RID: 1901 RVA: 0x00300AE8 File Offset: 0x002FECE8
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x0600076E RID: 1902 RVA: 0x00300AF8 File Offset: 0x002FECF8
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.ParameterDeclarations != null)
			{
				this.ParameterDeclarations.acceptChildren(v);
			}
			if (this.BodyStatements.size() > 0)
			{
				this.BodyStatements.acceptChildren(v);
			}
			v.postVisit(this);
		}

		// Token: 0x040011E2 RID: 4578
		private TObjectName procedureName;
	}
}
